package com.example.miscontactos.Entidades;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class EnviarMensajeHandler extends DefaultHandler 
{
	private MensajesWebsEntity mensajeWeb;
	private StringBuilder texto;
	private final String RESULT = "result";
	private final String DETAIL = "detail";
	private final String DESCRIPTION = "description";
	private final String PASS = "password";
	
	public MensajesWebsEntity getMensajeWebResponse()
	{
		return mensajeWeb;
	}
	
	@Override
	public void characters(char[] ch, int start, int length) throws SAXException
	{
		super.characters(ch, start, length);
		//if (this.usuarioWeb != null)
			//texto.append(ch, start, length);
	}
	
	 @Override 
	  public void startElement(String namespaceURI, String localName, String qName, Attributes atr) throws SAXException 
	  {
		 if(localName.equals(RESULT))
		 { 	 
			 mensajeWeb = new MensajesWebsEntity();
		 }
		 else
		 {
			 if(localName.equals(DETAIL))
			 {
				 if (atr.getValue(DESCRIPTION) != null)
					 mensajeWeb.error = atr.getValue("description");
			 }
		 }
	  } 
}
